"""
利用Python进行数据分析

读写文本格式的数据

pandas
"""
import pandas as pd


def read_test_01():
    """
    读取一个以逗号隔开的csv文件数据到DataFrame
    :return:
    """
    # print("---------------ex1.csv-----------------")
    # df = pd.read_csv('ex1.csv')
    # print(df)

    # print("---------------read_tale-----------------")
    #
    # df2 = pd.read_table('ex1.csv', delimiter=',')
    # print(df2)

    # print("---------------ex2.csv-----------------")
    # df2 = pd.read_csv('ex2.csv', header=None)
    # print(df2)

    # print("---------------ex2.csv-----------------")
    # df3 = pd.read_csv('ex2.csv', names=['a', 'b', 'c', 'd', 'message'])
    # print(df3)

    # print("---------------ex2.csv-----------------")
    # names = ['a', 'b', 'c', 'd', 'message']
    # df4 = pd.read_csv('ex2.csv', names=names, index_col='message')
    # print(df4)

    # print("---------------csv_mindex.csv-----------------")
    # parsed = pd.read_csv('csv_mindex.csv', index_col=['key1', 'key2'], skiprows=[0, 2])
    # print(parsed)

    # print("---------------ex5.csv-----------------")
    # result = pd.read_csv('ex5.csv')
    # print(result)
    # print(pd.isnull(result))

    # print("---------------ex5.csv-----------------")
    # result = pd.read_csv('ex5.csv', na_values=['NULL'])
    # print(result)

    print("---------------ex5.csv-----------------")
    sentinels = {'message': ['foo', 'NA'], 'something': ['two']}
    result = pd.read_csv('ex5.csv', na_values=sentinels)
    print(result)


def main():
    read_test_01()


if __name__ == '__main__':
    main()
